package com.test.pattern.iterator;

/**
 * @ClassName: Client
 * @description:
 * @author: Mr du
 * @create: 2024-03-17 18:06
 */
public class Client {

    public static void main(String[] args) {
        //创建聚合对象
        StudentAggregate studentAggregate = new StudentAggregateImpl();
        studentAggregate.addStudent(new Student("张三","001"));
        studentAggregate.addStudent(new Student("李四","002"));
        studentAggregate.addStudent(new Student("王五","003"));
        studentAggregate.addStudent(new Student("赵六","004"));
        studentAggregate.addStudent(new Student("秦七","005"));
        //获取迭代器对象
        StudentIterator iterator = studentAggregate.getStudentIterator();
        //遍历迭代器
        while (iterator.hashNext()){
            System.out.println(iterator.next());
        }
    }
}
